@layout("/common/_form.html",{js:["/assets/modular/system/btyTxl/btyTxl_addfzr.js"]}){
<link rel="stylesheet" type="text/css" href="/assets/modular/system/jq/jquery-ui.min.css">
<form class="layui-form" id="noticeForm" lay-filter="noticeForm">
    <div class="layui-fluid" style="padding-bottom: 75px;">
        <div class="layui-card">
            <div class="layui-card-header"></div>
            <div class="layui-card-body">
                <div class="layui-form-item layui-row">
                    <input name="roleId" type="hidden"/>
                    <div class="layui-inline layui-col-md6">
                        <label class="layui-form-label">请选择职位<span style="color: red;">*</span></label>
                        <div class="layui-input-block">
                            <select name="zw" id="zw" lay-verify="required" required>
                                <option value="督导/大店长">督导/大店长</option>
                                <option value="店长">店长</option>
                                <option value="店助">店助</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline layui-col-md6">
                        <label class="layui-form-label">负责人<span style="color: red;">*</span></label>
                        <div class="layui-input-block">
                            <input name="fzr" placeholder="请输入负责人" id="fzr" onclick="hhh()"
                                   style="position:absolute;z-index:2;width:100%;"
                                   autocomplete="off" lay-verify="required" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-md6">
                        <label class="layui-form-label">联系方式<span style="color: red;">*</span></label>
                        <div class="layui-input-block">
                            <input name="lxfs" id="lxfs" placeholder="请输入联系方式" lay-verify="required"
                                   class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-md6">
                        <label class="layui-form-label">所属餐厅 <span style="color: red;">*</span></label>
                        <div class="layui-input-block">
                            <input name="ssctdm" placeholder="请输入所属餐厅 " lay-verify="required" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline layui-col-md6">
                        <label class="layui-form-label">所属餐厅编号 <span style="color: red;">*</span></label>
                        <div class="layui-input-block">
                            <input name="ssctbh" placeholder="请输入所属餐厅编号 " lay-verify="required" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <div class="form-group-bottom text-center">
        <button class="layui-btn" lay-filter="btnSubmit" lay-submit>&emsp;提交&emsp;</button>
        <button type="reset" class="layui-btn layui-btn-primary" ew-event="closeDialog">&emsp;取消&emsp;</button>
    </div>
</form>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.js"></script>
<script src="/assets/modular/system/jq/jquery-ui.min.js"></script>
<script>

    function hhh() {
        var zw = $('#zw').val();
        if (zw == "督导/大店长") {
            const url = "selectTerm?term=";
            //先获取到职位的值 如果是大店长 再调用下面的方法
            $('#fzr').autocomplete({
                source: function (request, response) {
                    var term = request.term;
                    $.ajax({
                        type: "POST",
                        url: url + request.term,
                        async: false,
                        contentType: 'application/json',
                        success: function (data) {
                            response($.map(data, function (item) {
                                return {
                                    label: item.fzr,
                                    phone: item.lxfs
                                };
                            }));
                        },
                    });
                },
                focus: function (event, ui) {
                    return false;
                },
                select: function (event, ui) {
                    $("#fzr").val(ui.item.label);
                    let phone = ui.item.phone;
                    $("#lxfs").val(phone);
                    return false;
                }
            });
        }
    }

</script>
@}
